/*
*/

#include "search.h"

#include "beam.h"
#include "display.h"
#include "event.h"
#include "timer.h"

static u32 Press(u32 evn){
    u32	key;

    switch(key=GetKey(evn)){
    case KEY___TV:
    case KEY_CABL:
    case KEY__DVD:
    case KEY__AUX:
	page=key-KEY___TV;
	IndicatorOn();
	return STT_NIL;
    }
    do evn=WaitEvent();
    while(evn!=EVN_KEYRELEASE);
    return STT_SEARCH;
}

u32 Search(u32 stt){
    u32	evn,t_m;

    FlashAll();
    t_m=Timer();
    while(stt==STT_SEARCH){
	evn=WaitEvent();
	if((evn&EVN_MASK)==EVN_KEYPRESS){
	    stt=Press(evn);
	    t_m=Timer();
	}
	if(TimeOut(t_m,TIM_OUT)){
	    stt=STT_NIL;
	    IndicatorOff();
	}
    }
    return stt;
}
